package com.lftea.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.lftea.dao.ISaleDetailDAO;
import com.lftea.po.SaleDetail;

@Repository("saleDetailDAOImpl")
public class SaleDetailDAOImpl implements ISaleDetailDAO {

	@Resource(name = "jdbcTemplate")
	private JdbcTemplate jdbcTemplate;

	public List<SaleDetail> findAll() {
		String sql = "select * from SaleDetail";
		return jdbcTemplate.query(sql, new SaleDetailMapper());
	}

	public SaleDetail findById(long saleDetailId) {
		String sql = "select * from SaleDetail where Sale_Detail_ID=?";
		return (SaleDetail) jdbcTemplate.query(sql,
				new Object[] { saleDetailId }, new SaleDetailMapper());
	}

	public void remove(SaleDetail saleDetail) {
		long saleDetailId = saleDetail.getSaleDatailId();
		saleDetail.getSaleDatailId();
		String sql = "delete SaleDetail where Sale_Detail_ID=?";
		jdbcTemplate.update(sql,new Object[]{saleDetailId});
	}

	public void save(SaleDetail saleDetail) {
		saleDetail.getSaleDatailId();

		
	}

	public Set<SaleDetail> findBySaleId(long saleId) {
		// TODO Auto-generated method stub
		return null;
	}

	private final class SaleDetailMapper implements RowMapper<SaleDetail> {

		public SaleDetail mapRow(ResultSet rs, int rowNum) throws SQLException {
			// TODO

			return null;
		}

	}

}
